﻿Public Class F_Report
    Dim thang, nam As Integer
    Sub KiemTraThamSo()
        Try
            thang = ComboBox_thang.SelectedItem
            nam = Integer.Parse(TextBox_nam.Text)
        Catch ex As Exception
            MessageBox.Show("Kiểm tra thông tin!", "Thông báo", MessageBoxButtons.OK)
        End Try
        
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim rpt As New rptThu
        Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
        Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
        For Each tbCurrent In rpt.Database.Tables
            tliCurrent = tbCurrent.LogOnInfo
            With tliCurrent.ConnectionInfo
                .ServerName = Application.StartupPath + "\QLTCCN.mdb"
                '.UserID = ""
                '.Password = ""
                '.DatabaseName = ""
            End With
            tbCurrent.ApplyLogOnInfo(tliCurrent)
        Next tbCurrent
        KiemTraThamSo()
        rpt.SetParameterValue("NguoiThuPara", Me.Tag)
        rpt.SetParameterValue("ThangPara", thang)
        rpt.SetParameterValue("NamPara", nam)
        CrystalReportViewer1.ReportSource = rpt
    End Sub

    Private Sub btnbcchi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbcchi.Click
        Dim rpt As New rptChi
        Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
        Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
        For Each tbCurrent In rpt.Database.Tables
            tliCurrent = tbCurrent.LogOnInfo
            With tliCurrent.ConnectionInfo
                .ServerName = Application.StartupPath + "\QLTCCN.mdb"
                '.UserID = ""
                '.Password = ""
                '.DatabaseName = ""
            End With
            tbCurrent.ApplyLogOnInfo(tliCurrent)
        Next tbCurrent
        KiemTraThamSo()
        rpt.SetParameterValue("NguoiChiPara", Me.Tag)
        rpt.SetParameterValue("ThangPara", thang)
        rpt.SetParameterValue("NamPara", nam)
        CrystalReportViewer1.ReportSource = rpt
    End Sub

    Private Sub F_Report_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBox_thang.SelectedIndex = Now.Month - 1
        TextBox_nam.Text = Now.Year.ToString()
    End Sub

    Private Sub Button_bieudo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_bieudo.Click
        Dim rpt As New rptbieudo
        Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
        For Each tbCurrent In rpt.Database.Tables
            tliCurrent = tbCurrent.LogOnInfo
            With tliCurrent.ConnectionInfo
                .ServerName = Application.StartupPath + "\QLTCCN.mdb"
                '.UserID = ""
                '.Password = ""
                '.DatabaseName = ""
            End With
            tbCurrent.ApplyLogOnInfo(tliCurrent)
        Next tbCurrent
        KiemTraThamSo()
        rpt.SetParameterValue("UserPara", Me.Tag)
        CrystalReportViewer1.ReportSource = rpt
    End Sub
End Class